Optimal. Leaf size=195 \[ \frac {a^2}{e \left (f+\frac {e}{x}\right )}-\frac {2 a b d \cos \left (c-\frac {d f}{e}\right ) \text {Ci}\left (d \left (\frac {f}{e}+\frac {1}{x}\right )\right )}{e^2}-\frac {b^2 d \text {Ci}\left (2 d \left (\frac {f}{e}+\frac {1}{x}\right )\right ) \sin \left (2 c-\frac {2 d f}{e}\right )}{e^2}+\frac {2 a b \sin \left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}+\frac {b^2 \sin ^2\left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}+\frac {2 a b d \sin \left (c-\frac {d f}{e}\right ) \text {Si}\left (d \left (\frac {f}{e}+\frac {1}{x}\right )\right )}{e^2}-\frac {b^2 d \cos \left (2 c-\frac {2 d f}{e}\right ) \text {Si}\left (2 d \left (\frac {f}{e}+\frac {1}{x}\right )\right )}{e^2} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.27, antiderivative size = 195, normalized size of antiderivative = 1.00, number of steps
used = 12, number of rules used = 8, integrand size = 22, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.364, Rules used = {3512, 3398,
3378, 3384, 3380, 3383, 3394, 12} \begin {gather*} \frac {a^2}{e \left (\frac {e}{x}+f\right )}-\frac {2 a b d \cos \left (c-\frac {d f}{e}\right ) \text {CosIntegral}\left (d \left (\frac {f}{e}+\frac {1}{x}\right )\right )}{e^2}+\frac {2 a b d \sin \left (c-\frac {d f}{e}\right ) \text {Si}\left (d \left (\frac {f}{e}+\frac {1}{x}\right )\right )}{e^2}+\frac {2 a b \sin \left (c+\frac {d}{x}\right )}{e \left (\frac {e}{x}+f\right )}-\frac {b^2 d \sin \left (2 c-\frac {2 d f}{e}\right ) \text {CosIntegral}\left (2 d \left (\frac {f}{e}+\frac {1}{x}\right )\right )}{e^2}-\frac {b^2 d \cos \left (2 c-\frac {2 d f}{e}\right ) \text {Si}\left (2 d \left (\frac {f}{e}+\frac {1}{x}\right )\right )}{e^2}+\frac {b^2 \sin ^2\left (c+\frac {d}{x}\right )}{e \left (\frac {e}{x}+f\right )} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 3378
Rule 3380
Rule 3383
Rule 3384
Rule 3394
Rule 3398
Rule 3512
Rubi steps
\begin {align*} \int \frac {\left (a+b \sin \left (c+\frac {d}{x}\right )\right )^2}{(e+f x)^2} \, dx &=-\text {Subst}\left (\int \frac {(a+b \sin (c+d x))^2}{(f+e x)^2} \, dx,x,\frac {1}{x}\right )\\ &=-\text {Subst}\left (\int \left (\frac {a^2}{(f+e x)^2}+\frac {2 a b \sin (c+d x)}{(f+e x)^2}+\frac {b^2 \sin ^2(c+d x)}{(f+e x)^2}\right ) \, dx,x,\frac {1}{x}\right )\\ &=\frac {a^2}{e \left (f+\frac {e}{x}\right )}-(2 a b) \text {Subst}\left (\int \frac {\sin (c+d x)}{(f+e x)^2} \, dx,x,\frac {1}{x}\right )-b^2 \text {Subst}\left (\int \frac {\sin ^2(c+d x)}{(f+e x)^2} \, dx,x,\frac {1}{x}\right )\\ &=\frac {a^2}{e \left (f+\frac {e}{x}\right )}+\frac {2 a b \sin \left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}+\frac {b^2 \sin ^2\left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}-\frac {(2 a b d) \text {Subst}\left (\int \frac {\cos (c+d x)}{f+e x} \, dx,x,\frac {1}{x}\right )}{e}-\frac {\left (2 b^2 d\right ) \text {Subst}\left (\int \frac {\sin (2 c+2 d x)}{2 (f+e x)} \, dx,x,\frac {1}{x}\right )}{e}\\ &=\frac {a^2}{e \left (f+\frac {e}{x}\right )}+\frac {2 a b \sin \left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}+\frac {b^2 \sin ^2\left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}-\frac {\left (b^2 d\right ) \text {Subst}\left (\int \frac {\sin (2 c+2 d x)}{f+e x} \, dx,x,\frac {1}{x}\right )}{e}-\frac {\left (2 a b d \cos \left (c-\frac {d f}{e}\right )\right ) \text {Subst}\left (\int \frac {\cos \left (\frac {d f}{e}+d x\right )}{f+e x} \, dx,x,\frac {1}{x}\right )}{e}+\frac {\left (2 a b d \sin \left (c-\frac {d f}{e}\right )\right ) \text {Subst}\left (\int \frac {\sin \left (\frac {d f}{e}+d x\right )}{f+e x} \, dx,x,\frac {1}{x}\right )}{e}\\ &=\frac {a^2}{e \left (f+\frac {e}{x}\right )}-\frac {2 a b d \cos \left (c-\frac {d f}{e}\right ) \text {Ci}\left (\frac {d \left (f+\frac {e}{x}\right )}{e}\right )}{e^2}+\frac {2 a b \sin \left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}+\frac {b^2 \sin ^2\left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}+\frac {2 a b d \sin \left (c-\frac {d f}{e}\right ) \text {Si}\left (\frac {d \left (f+\frac {e}{x}\right )}{e}\right )}{e^2}-\frac {\left (b^2 d \cos \left (2 c-\frac {2 d f}{e}\right )\right ) \text {Subst}\left (\int \frac {\sin \left (\frac {2 d f}{e}+2 d x\right )}{f+e x} \, dx,x,\frac {1}{x}\right )}{e}-\frac {\left (b^2 d \sin \left (2 c-\frac {2 d f}{e}\right )\right ) \text {Subst}\left (\int \frac {\cos \left (\frac {2 d f}{e}+2 d x\right )}{f+e x} \, dx,x,\frac {1}{x}\right )}{e}\\ &=\frac {a^2}{e \left (f+\frac {e}{x}\right )}-\frac {2 a b d \cos \left (c-\frac {d f}{e}\right ) \text {Ci}\left (\frac {d \left (f+\frac {e}{x}\right )}{e}\right )}{e^2}-\frac {b^2 d \text {Ci}\left (\frac {2 d \left (f+\frac {e}{x}\right )}{e}\right ) \sin \left (2 c-\frac {2 d f}{e}\right )}{e^2}+\frac {2 a b \sin \left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}+\frac {b^2 \sin ^2\left (c+\frac {d}{x}\right )}{e \left (f+\frac {e}{x}\right )}+\frac {2 a b d \sin \left (c-\frac {d f}{e}\right ) \text {Si}\left (\frac {d \left (f+\frac {e}{x}\right )}{e}\right )}{e^2}-\frac {b^2 d \cos \left (2 c-\frac {2 d f}{e}\right ) \text {Si}\left (\frac {2 d \left (f+\frac {e}{x}\right )}{e}\right )}{e^2}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.94, size = 263, normalized size = 1.35 \begin {gather*} -\frac {2 a^2 e^2+b^2 e^2+b^2 e f x \cos \left (2 \left (c+\frac {d}{x}\right )\right )+4 a b d f (e+f x) \cos \left (c-\frac {d f}{e}\right ) \text {Ci}\left (d \left (\frac {f}{e}+\frac {1}{x}\right )\right )+2 b^2 d f (e+f x) \text {Ci}\left (2 d \left (\frac {f}{e}+\frac {1}{x}\right )\right ) \sin \left (2 c-\frac {2 d f}{e}\right )-4 a b e f x \sin \left (c+\frac {d}{x}\right )-4 a b d e f \sin \left (c-\frac {d f}{e}\right ) \text {Si}\left (d \left (\frac {f}{e}+\frac {1}{x}\right )\right )-4 a b d f^2 x \sin \left (c-\frac {d f}{e}\right ) \text {Si}\left (d \left (\frac {f}{e}+\frac {1}{x}\right )\right )+2 b^2 d e f \cos \left (2 c-\frac {2 d f}{e}\right ) \text {Si}\left (2 d \left (\frac {f}{e}+\frac {1}{x}\right )\right )+2 b^2 d f^2 x \cos \left (2 c-\frac {2 d f}{e}\right ) \text {Si}\left (2 d \left (\frac {f}{e}+\frac {1}{x}\right )\right )}{2 e^2 f (e+f x)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.14, size = 313, normalized size = 1.61
method | result | size |
derivativedivides | \(-d \left (-\frac {a^{2}}{\left (-c e +d f +e \left (c +\frac {d}{x}\right )\right ) e}+2 a b \left (-\frac {\sin \left (c +\frac {d}{x}\right )}{\left (-c e +d f +e \left (c +\frac {d}{x}\right )\right ) e}+\frac {-\frac {\sinIntegral \left (-\frac {d}{x}-c -\frac {-c e +d f}{e}\right ) \sin \left (\frac {-c e +d f}{e}\right )}{e}+\frac {\cosineIntegral \left (\frac {d}{x}+c +\frac {-c e +d f}{e}\right ) \cos \left (\frac {-c e +d f}{e}\right )}{e}}{e}\right )-\frac {b^{2}}{2 \left (-c e +d f +e \left (c +\frac {d}{x}\right )\right ) e}-\frac {b^{2} \left (-\frac {2 \cos \left (\frac {2 d}{x}+2 c \right )}{\left (-c e +d f +e \left (c +\frac {d}{x}\right )\right ) e}-\frac {2 \left (-\frac {2 \sinIntegral \left (-\frac {2 d}{x}-2 c -\frac {2 \left (-c e +d f \right )}{e}\right ) \cos \left (\frac {-2 c e +2 d f}{e}\right )}{e}-\frac {2 \cosineIntegral \left (\frac {2 d}{x}+2 c +\frac {-2 c e +2 d f}{e}\right ) \sin \left (\frac {-2 c e +2 d f}{e}\right )}{e}\right )}{e}\right )}{4}\right )\) | \(313\) |
default | \(-d \left (-\frac {a^{2}}{\left (-c e +d f +e \left (c +\frac {d}{x}\right )\right ) e}+2 a b \left (-\frac {\sin \left (c +\frac {d}{x}\right )}{\left (-c e +d f +e \left (c +\frac {d}{x}\right )\right ) e}+\frac {-\frac {\sinIntegral \left (-\frac {d}{x}-c -\frac {-c e +d f}{e}\right ) \sin \left (\frac {-c e +d f}{e}\right )}{e}+\frac {\cosineIntegral \left (\frac {d}{x}+c +\frac {-c e +d f}{e}\right ) \cos \left (\frac {-c e +d f}{e}\right )}{e}}{e}\right )-\frac {b^{2}}{2 \left (-c e +d f +e \left (c +\frac {d}{x}\right )\right ) e}-\frac {b^{2} \left (-\frac {2 \cos \left (\frac {2 d}{x}+2 c \right )}{\left (-c e +d f +e \left (c +\frac {d}{x}\right )\right ) e}-\frac {2 \left (-\frac {2 \sinIntegral \left (-\frac {2 d}{x}-2 c -\frac {2 \left (-c e +d f \right )}{e}\right ) \cos \left (\frac {-2 c e +2 d f}{e}\right )}{e}-\frac {2 \cosineIntegral \left (\frac {2 d}{x}+2 c +\frac {-2 c e +2 d f}{e}\right ) \sin \left (\frac {-2 c e +2 d f}{e}\right )}{e}\right )}{e}\right )}{4}\right )\) | \(313\) |
risch | \(\frac {a b d \,{\mathrm e}^{-\frac {i \left (c e -d f \right )}{e}} \expIntegral \left (1, \frac {i d}{x}+i c -\frac {i \left (c e -d f \right )}{e}\right )}{e^{2}}-\frac {a^{2}}{f \left (f x +e \right )}-\frac {b^{2}}{2 f \left (f x +e \right )}+\frac {i d \,b^{2} {\mathrm e}^{-\frac {2 i \left (c e -d f \right )}{e}} \expIntegral \left (1, \frac {2 i d}{x}+2 i c -\frac {2 i \left (c e -d f \right )}{e}\right )}{2 e^{2}}-\frac {i d \,b^{2} {\mathrm e}^{\frac {2 i \left (c e -d f \right )}{e}} \expIntegral \left (1, -\frac {2 i d}{x}-2 i c -\frac {2 \left (-i c e +i d f \right )}{e}\right )}{2 e^{2}}+\frac {a b d \,{\mathrm e}^{\frac {i \left (c e -d f \right )}{e}} \expIntegral \left (1, -\frac {i d}{x}-i c -\frac {-i c e +i d f}{e}\right )}{e^{2}}+\frac {2 i a b d \sin \left (\frac {c x +d}{x}\right )}{e \left (-i c e +e \left (i c +\frac {i d}{x}\right )+i d f \right )}-\frac {i d \,b^{2} \cos \left (\frac {2 c x +2 d}{x}\right )}{2 e^{2} \left (\frac {i d}{x}+i c +\frac {-i c e +i d f}{e}\right )}\) | \(338\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Failed to integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.42, size = 348, normalized size = 1.78 \begin {gather*} -\frac {2 \, b^{2} f x \cos \left (\frac {c x + d}{x}\right )^{2} e - 4 \, a b f x e \sin \left (\frac {c x + d}{x}\right ) - b^{2} f x e + 2 \, {\left (b^{2} d f^{2} x + b^{2} d f e\right )} \cos \left (-2 \, {\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Si}\left (\frac {2 \, {\left (d f x + d e\right )} e^{\left (-1\right )}}{x}\right ) - 4 \, {\left (a b d f^{2} x + a b d f e\right )} \sin \left (-{\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Si}\left (\frac {{\left (d f x + d e\right )} e^{\left (-1\right )}}{x}\right ) + 2 \, {\left ({\left (a b d f^{2} x + a b d f e\right )} \operatorname {Ci}\left (\frac {{\left (d f x + d e\right )} e^{\left (-1\right )}}{x}\right ) + {\left (a b d f^{2} x + a b d f e\right )} \operatorname {Ci}\left (-\frac {{\left (d f x + d e\right )} e^{\left (-1\right )}}{x}\right )\right )} \cos \left (-{\left (d f - c e\right )} e^{\left (-1\right )}\right ) + {\left (2 \, a^{2} + b^{2}\right )} e^{2} + {\left ({\left (b^{2} d f^{2} x + b^{2} d f e\right )} \operatorname {Ci}\left (\frac {2 \, {\left (d f x + d e\right )} e^{\left (-1\right )}}{x}\right ) + {\left (b^{2} d f^{2} x + b^{2} d f e\right )} \operatorname {Ci}\left (-\frac {2 \, {\left (d f x + d e\right )} e^{\left (-1\right )}}{x}\right )\right )} \sin \left (-2 \, {\left (d f - c e\right )} e^{\left (-1\right )}\right )}{2 \, {\left (f^{2} x e^{2} + f e^{3}\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\left (a + b \sin {\left (c + \frac {d}{x} \right )}\right )^{2}}{\left (e + f x\right )^{2}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 700 vs.
\(2 (183) = 366\).
time = 7.18, size = 700, normalized size = 3.59 \begin {gather*} -\frac {4 \, a b d^{3} f \cos \left (-{\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Ci}\left ({\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) - 4 \, a b c d^{2} \cos \left (-{\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Ci}\left ({\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) e + 2 \, b^{2} d^{3} f \operatorname {Ci}\left (2 \, {\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) \sin \left (-2 \, {\left (d f - c e\right )} e^{\left (-1\right )}\right ) - 2 \, b^{2} c d^{2} \operatorname {Ci}\left (2 \, {\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) e \sin \left (-2 \, {\left (d f - c e\right )} e^{\left (-1\right )}\right ) + 4 \, a b d^{3} f \sin \left (-{\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Si}\left (-{\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) - 4 \, a b c d^{2} e \sin \left (-{\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Si}\left (-{\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) - 2 \, b^{2} d^{3} f \cos \left (-2 \, {\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Si}\left (-2 \, {\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) + 2 \, b^{2} c d^{2} \cos \left (-2 \, {\left (d f - c e\right )} e^{\left (-1\right )}\right ) e \operatorname {Si}\left (-2 \, {\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) + \frac {4 \, {\left (c x + d\right )} a b d^{2} \cos \left (-{\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Ci}\left ({\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) e}{x} + \frac {2 \, {\left (c x + d\right )} b^{2} d^{2} \operatorname {Ci}\left (2 \, {\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right ) e \sin \left (-2 \, {\left (d f - c e\right )} e^{\left (-1\right )}\right )}{x} + \frac {4 \, {\left (c x + d\right )} a b d^{2} e \sin \left (-{\left (d f - c e\right )} e^{\left (-1\right )}\right ) \operatorname {Si}\left (-{\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right )}{x} - \frac {2 \, {\left (c x + d\right )} b^{2} d^{2} \cos \left (-2 \, {\left (d f - c e\right )} e^{\left (-1\right )}\right ) e \operatorname {Si}\left (-2 \, {\left (d f - c e + \frac {{\left (c x + d\right )} e}{x}\right )} e^{\left (-1\right )}\right )}{x} + b^{2} d^{2} \cos \left (\frac {2 \, {\left (c x + d\right )}}{x}\right ) e - 4 \, a b d^{2} e \sin \left (\frac {c x + d}{x}\right ) - 2 \, a^{2} d^{2} e - b^{2} d^{2} e}{2 \, {\left (d f e^{2} - c e^{3} + \frac {{\left (c x + d\right )} e^{3}}{x}\right )} d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.01 \begin {gather*} \int \frac {{\left (a+b\,\sin \left (c+\frac {d}{x}\right )\right )}^2}{{\left (e+f\,x\right )}^2} \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________